package jrobutt;

import java.awt.*;
import java.awt.geom.*;
import java.util.*;

public abstract class GameRoom
{
    protected abstract Collection<? extends KeyboardResponder> getKeyboardResponders ();
    protected abstract Collection<? extends Updatable> getUpdatables ();
    protected abstract Collection<? extends Renderable> getRenderables ();
    
    public abstract Color get_bg_color ();
    
    public abstract void enter ();
    public abstract void exit ();
    
    public GameRoom key_pressed (int key)
    {
        for (KeyboardResponder r : getKeyboardResponders()) r.key_pressed(key);
        return null;
    }
    public GameRoom key_released (int key)
    {
        for (KeyboardResponder r : getKeyboardResponders()) r.key_released(key);
        return null;
    }
    
    public GameRoom update ()
    {
        for (Updatable u : getUpdatables()) u.update();
        return null;
    }
    
    public void render (Graphics2D g)
    {
        AffineTransform prev_transform = g.getTransform();
        for (Renderable r : getRenderables()) r.render(g);
        g.setTransform(prev_transform);
    }
}
